#include "Salle.h"
#include "Issue.h"

Salle::Salle(string nom) {
	this->nom = nom;
	
}

Salle::~Salle() {
	
}

string Salle::toString() {
	string s = "";
	s += "nom=";
	s += this->nom;
	
	map<Direction, Issue *>::iterator iter;
	Direction tempDirection;
	Issue *tempIssue;
	for (iter = this->issues.begin(); iter != this->issues.end(); iter++ ) {
		tempDirection = (Direction) iter->first;
		s += ", direction=";
		s += intToString(tempDirection);
		tempIssue = (Issue *) iter->second;
		s += ", issue=";
		s += tempIssue->rapport();
	}
	
	return s;
}

void Salle::ajouteIssue(Direction direction, Issue *issue) {
	this->issues[direction] = issue;
}

void Salle::supprimeIssue(Direction direction) {
	this->issues.erase(direction);
}

Issue *Salle::getIssue(Direction direction) {
	return this->issues[direction];
}

// TODO
/*
void Salle::ajouteObjet(Objet *objet) {
	
}

Liste<Element> &Salle::prendreObjets() {
	return NULL;
}

void Salle::prendreObjets(Liste<Element> &objets) {
	
}
*/
ostream& operator <<(ostream &os, const Salle &salle) {
	os << "	nom=";
	os << salle.nom;
	
	map<Direction, Issue *> zob;
	map<Direction, Issue *>::const_iterator iter = salle.issues.begin();
	Direction tempDirection;
	Issue *tempIssue;
	for (iter = salle.issues.begin(); iter != salle.issues.end(); iter++ ) {
		tempDirection = (Direction) iter->first;
		os << ",\n	Issue : \n		direction=";
		os << tempDirection;
		tempIssue = (Issue *) iter->second;
		os << ", ";
		os << tempIssue->rapport();
	}
	return os;
}

ostream& operator<<( ostream& os, const Direction& direction){
	switch (direction) {
		case NORD: os << "NORD"; break;
		case EST: os << "EST"; break;
		case SUD: os << "SUD"; break;
		case OUEST: os << "OUEST"; break;
	}
	return os;
}
